package org.xx.armory.mbeans;

import org.xx.armory.Application;
import org.xx.armory.mbeans.ApplicationProxyMBean;

import static org.xx.armory.commons.Validators.notNull;

public class ApplicationProxy
        implements ApplicationProxyMBean {
    /**
     * 用于注册JMXBean的域名。
     */
    public final static String JMX_DOMAIN = "org.xx.armory";

    private final Application application;

    public ApplicationProxy(
            Application application
    ) {
        this.application = notNull(application, "application");
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getName() {
        return this.application.getName();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getDescription() {
        return this.application.getDescription();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getStatus() {
        return this.application.getStatus();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void start()
            throws Exception {
        this.application.start();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void shutdown()
            throws Exception {
        this.application.shutdown();
    }
}
